package com.terrynoya.fight.stateMachine.triggers
{
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.emuns.SymbolType;
	import com.terrynoya.fight.evaluation.Node;
	import com.terrynoya.fight.evaluation.ParseState;

	public class Const
	{
		public static const VELOCITY_WALK_FWD_X:String = "velocity.walk.fwd.x";
		public static const VELOCITY_WALK_BACK_X:String = "velocity.walk.back.x";
		public static const VELOCITY_JUMP_Y:String = "velocity.jump.y";
		public static const VELOCITY_JUMP_NEU_X:String = "velocity.jump.neu.x";
		public static const VELOCITY_JUMP_FWD_X:String = "velocity.jump.fwd.x";
		public static const VELOCITY_JUMP_BACK_X:String = "velocity.jump.back.x";
		public static const LIE_DOWN_TIME:String = "data.liedown.time";
		public static const MOVEMENT_YACCEL:String = "movement.yaccel"
		
		
		public function Const()
		{
		}
		
		public static function eval(data:Object,node:Node):*
		{
			var chara:Character = data as Character;
			if(chara == null)
			{
				return 0;
			}
			var val:String = node.arguments[0];
			switch(val)
			{
				case VELOCITY_WALK_FWD_X:
				{
					return chara.playerConst.walkForward;
					break;
				}
				case VELOCITY_WALK_BACK_X:
				{
					return chara.playerConst.walkBackward;
					break;
				}
				case VELOCITY_JUMP_Y:
				{
					return chara.playerConst.jumpNeutral.y;
					break;
				}
				case VELOCITY_JUMP_FWD_X:
				{
					return chara.playerConst.jumpForward.x;
					break;
				}
				case VELOCITY_JUMP_BACK_X:
				{
					return chara.playerConst.jumpBack.x;
					break;
				}
				case VELOCITY_JUMP_NEU_X:
				{
					return chara.playerConst.jumpNeutral.x;
					break;
				}
				case LIE_DOWN_TIME:
				{
					return chara.playerConst.liedowntime;
					break;
				}
				case MOVEMENT_YACCEL:
				{
					return chara.playerConst.vertAcceleration;
					break;
				}
			}
		}
		
		public static function parse(state:ParseState):Node
		{
			if(state.currentSymbol != SymbolType.LeftParen)
			{
				return null;
			}
			state.tokenIndex ++;
			
			var constant:String = state.currentUnknown;
			if(constant == null)
			{
				return null;
			}
			state.baseNode.arguments.push(constant);
			
			state.tokenIndex ++;
			if(state.currentSymbol != SymbolType.RightParen)
			{
				return null;
			}
			state.tokenIndex ++;
			
			return state.baseNode;
		}
	}
}